feat(03-05_load_balancer): Add load-balancer endpoints example#13
Merged
feat(03-05_load_balancer): Add load-balancer endpoints example#13
Conversation
Create a comprehensive example demonstrating Flash's load-balancer endpoints with custom HTTP routes. This example shows how to create low-latency APIs using the @Remote decorator with method and path parameters. Key additions: - GPU service for compute-intensive operations - CPU service for data processing - Pydantic models for input validation - Comprehensive documentation with cost estimates and troubleshooting - LiveLoadBalancer for local development - LoadBalancerSlsResource configuration for production Improvements made: - Added pyproject.toml with project metadata - Added input validation using Pydantic models - Added Cost Estimates section to README - Added Troubleshooting section to README - Updated root README.md to include new example - Updated 03_advanced_workers/README.md to document the example All code passes quality checks: formatting, linting, and type checking.
Improvements: - Remove redundant validation in GPU worker (Pydantic already validates) - Use UTC timezone for all timestamps instead of local timezone - Extract VALID_OPERATIONS to module-level constant in CPU worker - Clarify port documentation in README Changes: - GPU endpoint.py: Remove redundant empty list check, use UTC timestamps - CPU endpoint.py: Add VALID_OPERATIONS constant, use UTC timestamps, simplify operation validation - README.md: Clarify port differences between standalone (8000) and unified app (8888) All changes pass quality checks.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive example demonstrating Flash's load-balancer endpoints with custom HTTP routes using the @remote decorator with method and path parameters.
Key Changes:
- Created a complete load-balancer example with GPU and CPU services
- Added comprehensive documentation including cost estimates and troubleshooting sections
- Updated repository documentation to include the new example
Reviewed changes
Copilot reviewed 14 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Added load_balancer example to the advanced workers section |
| CLAUDE.md | Updated naming convention comment for resource configuration |
| 03_advanced_workers/README.md | Added detailed documentation for the load_balancer example |
| 03_advanced_workers/05_load_balancer/workers/gpu/endpoint.py | Implemented GPU service endpoints with compute operations |
| 03_advanced_workers/05_load_balancer/workers/gpu/init.py | Created FastAPI router for GPU endpoints |
| 03_advanced_workers/05_load_balancer/workers/cpu/endpoint.py | Implemented CPU service endpoints with text processing operations |
| 03_advanced_workers/05_load_balancer/workers/cpu/init.py | Created FastAPI router for CPU endpoints |
| 03_advanced_workers/05_load_balancer/requirements.txt | Added tetra_rp dependency |
| 03_advanced_workers/05_load_balancer/pyproject.toml | Added project metadata and dependencies |
| 03_advanced_workers/05_load_balancer/main.py | Created unified FastAPI application |
| 03_advanced_workers/05_load_balancer/README.md | Added comprehensive documentation with examples and troubleshooting |
| 03_advanced_workers/05_load_balancer/.gitignore | Added standard Python and project-specific ignore patterns |
| 03_advanced_workers/05_load_balancer/.flashignore | Added Flash build ignore patterns |
| 03_advanced_workers/05_load_balancer/.env.example | Added environment variable template |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes: - Use ComputeRequest model as parameter in compute_intensive() function for proper type safety and validation - Update GPU router to pass full request object instead of extracting numbers - Update test code to create ComputeRequest object properly This ensures consistent use of Pydantic models for validation throughout the GPU worker endpoint. All changes pass quality checks.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 16 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…unction Remote functions with load-balancer decorators don't have access to custom types like Pydantic models in their execution context. Move ComputeRequest to the router module and convert it to a dict before passing to the remote function, matching the pattern used in the CPU worker.
jhcipar
approved these changes
Jan 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add comprehensive example demonstrating Flash's load-balancer endpoints with custom HTTP routes. This example shows how to create low-latency APIs using the
@remotedecorator with method and path parameters.Key Features
Changes Made
03_advanced_workers/05_load_balancer/Testing
Documentation